<?php
/*
 CREATE TABLE users ( 
	password varchar not null,
	email varchar not null,
	phone varchar not null,
	firstname varchar,
	middlename varchar,
	lastname varchar,
	is_active boolean default false,
	role uuid not null,
	PRIMARY KEY(id)
)  inherits (object);
 */
class Agitum_Orm_User extends Agitum_Orm_Object
{
    protected function init() 
    {
        parent::init();

        $this->name = 'user';
        $this->title = 'Пользователь';
       
        $this->schema['password'] = Agitum_Orm_Attribute::factory(
            Agitum_Orm_Attirbute_Type::Password, 
            array(
                'name' => 'password',
                'title' => 'Пароль',
                'sortOrder' => '60'
            )
        );
        
        $this->schema['email'] = Agitum_Orm_Attribute::factory(
            Agitum_Orm_Attirbute_Type::Email, 
            array(
                'name' => 'email',
                'title' => 'E-mail',
                'sortOrder' => '70'
            )
        );
        
        $this->schema['phone'] = Agitum_Orm_Attribute::factory(
            Agitum_Orm_Attirbute_Type::String, 
            array(
                'name' => 'phone',
                'title' => 'Телефон',
                'sortOrder' => '80'
            )
        );
        
        $this->schema['firstname'] = Agitum_Orm_Attribute::factory(
            Agitum_Orm_Attirbute_Type::String, 
            array(
                'name' => 'firstname',
                'title' => 'Имя',
                'sortOrder' => '90'
            )
        );
        
        $this->schema['middlename'] = Agitum_Orm_Attribute::factory(
            Agitum_Orm_Attirbute_Type::String, 
            array(
                'name' => 'middlename',
                'title' => 'Отчество',
                'sortOrder' => '100'
            )
        );
        
        $this->schema['lastname'] = Agitum_Orm_Attribute::factory(
            Agitum_Orm_Attirbute_Type::String, 
            array(
                'name' => 'lastname',
                'title' => 'Фамилия',
                'sortOrder' => '110'
            )
        );
        
        $this->schema['active'] = Agitum_Orm_Attribute::factory(
            Agitum_Orm_Attirbute_Type::Boolean, 
            array(
                'name' => 'active',
                'title' => 'Активен(?)',
                'sortOrder' => '120'
            )
        );
        
        $this->schema['role'] = Agitum_Orm_Attribute::factory(
            Agitum_Orm_Attirbute_Type::Object, 
            array(
                'name' => 'role',
                'title' => 'Персональная роль',
                'sortOrder' => '90'
            )
        );
        $this->schema['role']->setRelname('role');
    }
}
